﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Smugmug
{
    [TestClass]
    public class ConfigTests
    {
        [TestMethod]
        public void GetString_IfKeyDoesNotExist_ReturnDefaultValue()
        {
            string val = Config.GetString("NotFound", "Default");
            Assert.AreEqual("Default", val);
        }

        [TestMethod]
        public void GetString_IfKeyExists_ReturnsCorrectValue()
        {
            string val = Config.GetString("StringValue", "Value");
            Assert.AreEqual("Value", val);
        }

        [TestMethod]
        public void GetInt32_IfKeyDoesNotExist_ReturnDefaultValue()
        {
            int? val = Config.GetInt32("NotFoundInt", 101);
            Assert.IsTrue(val.HasValue);
            Assert.AreEqual(101, val.Value);
        }

        [TestMethod]
        public void GetInt32_IfKeyExists_ReturnsCorrectValue()
        {
            int? val = Config.GetInt32("Int32Value", 11);
            Assert.IsTrue(val.HasValue);
            Assert.AreEqual(10, val.Value);
        }

        [TestMethod]
        public void GetInt32_NonIntValue_ReturnsDefaultValue()
        {
            int? val = Config.GetInt32("StringValue", 11);
            Assert.IsTrue(val.HasValue);
            Assert.AreEqual(11, val.Value);
        }
    }
}